import type { UploadUserFile } from "element-plus";

// 获取SpuList所需要的参数的类型
export interface GetProductSpuParams {
  page: number;
  limit: number;
  category3Id?: number;
}
// 获取基础销售属性列表的类型(颜色、版本、尺码)
export type GetBaseSaleAttrList = GetBaseSaleAttrItem[];
export interface GetBaseSaleAttrItem {
  id: number;
  name: string;
}
// 展示SPU
export interface GetProductSPU {
  records: GetProductSPUList;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}

export type GetProductSPUList = GetProductSPUItem[];

export interface GetProductSPUItem {
  id?: number;
  spuName: string;
  description: string;
  category3Id?: number;
  tmId?: number;
}

// 由于在addOrUpdateSpu组件中使用时，spuImageList的类型和添加/更新SPU的类型不一致，所以分开写
export interface AddOrUpdateSpuParams extends GetProductSPUItem {
  spuImageList: SpuImageList;
  spuSaleAttrList: SpuSaleAttrList;
}
// 在addOrUpdateSpu组件中使用
export interface SpuFormData extends GetProductSPUItem {
  spuImageList: UploadUserFile[];
  spuSaleAttrList: SpuSaleAttrList;
}

export type SpuImageList = SpuImageItem[];

export interface SpuImageItem {
  id?: number;
  imgName: string;
  imgUrl: string;
  spuId?: number;
  isDefault?: "1" | "0";
}

export type SpuSaleAttrList = SpuSaleAttrItem[];

export interface SpuSaleAttrItem {
  baseSaleAttrId: number;
  id?: number;
  saleAttrName: string;
  isShowEdit?: boolean;
  spuId?: number;
  spuSaleAttrValueList: SpuSaleAttrValueList;
}

export type SpuSaleAttrValueList = SpuSaleAttrValueItem[];

export interface SpuSaleAttrValueItem {
  baseSaleAttrId: number;
  id?: number;
  isChecked?: string;
  saleAttrName?: string;
  saleAttrValueName: string;
  spuId?: number;
}

/**
 * SpuList展示数据类型spuList
 * 
  表单收集的数据spuFormData的类型
  {
    spuName: "",
    tmId: undefined,
    description: "",
    spuImageList: [],
    spuSaleAttrList: [],
  }
 * 添加Spu接口参数类型
  {
    "category3Id": 0,
    "description": "string",
    "id": 0,
    "spuImageList": [
      {
        "id": 0,
        "imgName": "string",
        "imgUrl": "string",
        "spuId": 0
      }
    ],
    "spuName": "string",
    "spuSaleAttrList": [
      {
        "baseSaleAttrId": 0,
        "id": 0,
        "saleAttrName": "string",
        "spuId": 0,
        "spuSaleAttrValueList": [
          {
            "baseSaleAttrId": 0,
            "id": 0,
            "isChecked": "string",
            "saleAttrName": "string",
            "saleAttrValueName": "string",
            "spuId": 0
          }
        ]
      }
    ],
    "tmId": 0
  }
 * 修改Spu接口参数类型
    {
    "category3Id": 0,
    "description": "string",
    "id": 0,
    "spuImageList": [
      {
        "id": 0,
        "imgName": "string",
        "imgUrl": "string",
        "spuId": 0
      }
    ],
    "spuName": "string",
    "spuSaleAttrList": [
      {
        "baseSaleAttrId": 0,
        "id": 0,
        "saleAttrName": "string",
        "spuId": 0,
        "spuSaleAttrValueList": [
          {
            "baseSaleAttrId": 0,
            "id": 0,
            "isChecked": "string",
            "saleAttrName": "string",
            "saleAttrValueName": "string",
            "spuId": 0
          }
        ]
      }
    ],
    "tmId": 0
  }
 */
